import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);//sc做输入相关的对象
        int n;
        while(true) {
            n = sc.nextInt();
            if(n == 0){
                break;
            }
            int[] dp = new int[n+1];
            dp[1] = 1;
            for(int i=2;i<=n;i++){
                if(i>3){
                    dp[i] = dp[i-1] + dp[i-3];
                }else{
                    dp[i] = dp[i-1] + 1;
                }
            }
            System.out.println(dp[n]);
        }
    }
}
